package ${projectConfig.basePackage}.${config.model}.dao.gen;

import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;
import java.math.BigDecimal;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import ${projectConfig.commPackage}.bean.PageBean;
import ${projectConfig.commPackage}.util.TypeCast;
import ${projectConfig.commPackage}.exception.ServiceException;
import ${projectConfig.beanPackage}.${config.model}.bean.bo.gen.${config.objectName};
import ${projectConfig.basePackage}.${config.model}.mapper.gen.${config.objectName}Mapper;
@Repository
public class ${config.objectName}Dao  {
	// 日志对象
	private transient Log log = LogFactory.getLog(this.getClass());
	@Autowired
	private ${config.objectName}Mapper ${config.objectName?uncap_first}Mapper;

<#list method as methodp>
  <#if methodp.outType == "String">
	public String ${methodp.name}(Map conditionMap){
		return ${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap);
	}
  <#elseif methodp.outType == "Integer">
	public Integer ${methodp.name}(<#if methodp.inType??><#if methodp.inType=="Object">${config.objectName} ${config.objectName?uncap_first}<#else>Map conditionMap</#if><#else>Map conditionMap</#if>){
		return ${config.objectName?uncap_first}Mapper.${methodp.name}(<#if methodp.inType??><#if methodp.inType=="Object">${config.objectName?uncap_first}<#else>conditionMap</#if><#else>conditionMap</#if>);
	}
  <#elseif methodp.outType == "ListInteger">
	public List<Integer> ${methodp.name}(Map conditionMap){
		return ${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap);
	}
	public PageBean ${methodp.name}Page(Map conditionMap,int pageNo,int pageSize){
		Integer count = ${methodp.name}Count(conditionMap);
		PageBean pageBean = new PageBean();
		pageBean.setCount(count);
		pageBean.setPageNo(pageNo);
		pageBean.setPageSize(pageSize);
		conditionMap.put("limitStart",pageBean.getStartNo());
		conditionMap.put("limitOffset",pageSize);
		pageBean.setData(${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap));
		return pageBean;
	}
	public Integer ${methodp.name}Count(Map conditionMap){
		return ${config.objectName?uncap_first}Mapper.${methodp.name}Count(conditionMap);
	}
  <#elseif methodp.outType == "Long">
    public Long ${methodp.name}(<#if methodp.inType??><#if methodp.inType=="Object">${config.objectName} ${config.objectName?uncap_first}<#else>Map conditionMap</#if><#else>Map conditionMap</#if>){
        return ${config.objectName?uncap_first}Mapper.${methodp.name}(<#if methodp.inType??><#if methodp.inType=="Object">${config.objectName?uncap_first}<#else>conditionMap</#if><#else>conditionMap</#if>);
    }
  <#elseif methodp.outType == "ListLong">
    public List<Long> ${methodp.name}(Map conditionMap){
        return ${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap);
    }
    public PageBean ${methodp.name}Page(Map conditionMap,int pageNo,int pageSize){
        Integer count = ${methodp.name}Count(conditionMap);
        PageBean pageBean = new PageBean();
        pageBean.setCount(count);
        pageBean.setPageNo(pageNo);
        pageBean.setPageSize(pageSize);
        conditionMap.put("limitStart",pageBean.getStartNo());
        conditionMap.put("limitOffset",pageSize);
        pageBean.setData(${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap));
        return pageBean;
    }
    public Integer ${methodp.name}Count(Map conditionMap){
        return ${config.objectName?uncap_first}Mapper.${methodp.name}Count(conditionMap);
    }
  <#elseif methodp.outType == "ListString">
	public List<String> ${methodp.name}(Map conditionMap){
		return ${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap);
	}
	public PageBean ${methodp.name}Page(Map conditionMap,int pageNo,int pageSize){
		Integer count = ${methodp.name}Count(conditionMap);
		PageBean pageBean = new PageBean();
		pageBean.setCount(count);
		pageBean.setPageNo(pageNo);
		pageBean.setPageSize(pageSize);
		conditionMap.put("limitStart",pageBean.getStartNo());
		conditionMap.put("limitOffset",pageSize);
		pageBean.setData(${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap));
		return pageBean;
	}
	public Integer ${methodp.name}Count(Map conditionMap){
		return ${config.objectName?uncap_first}Mapper.${methodp.name}Count(conditionMap);
	}
  <#elseif methodp.outType == "Object">
	public ${config.objectName} ${methodp.name}(Map conditionMap){
		return ${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap);
	}
  <#elseif methodp.outType == "Map">
	public Map ${methodp.name}(Map conditionMap){
		return ${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap);
	}
  <#elseif methodp.outType == "ListObject">
	public List<${config.objectName}> ${methodp.name}(Map conditionMap){
		return ${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap);
	}
	public PageBean ${methodp.name}Page(Map conditionMap,int pageNo,int pageSize){
		Integer count = ${methodp.name}Count(conditionMap);
		PageBean pageBean = new PageBean();
		pageBean.setCount(count);
		pageBean.setPageNo(pageNo);
		pageBean.setPageSize(pageSize);
		conditionMap.put("limitStart",pageBean.getStartNo());
		conditionMap.put("limitOffset",pageSize);
		pageBean.setData(${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap));
		return pageBean;
	}
	public Integer ${methodp.name}Count(Map conditionMap){
		return ${config.objectName?uncap_first}Mapper.${methodp.name}Count(conditionMap);
	}
<#elseif methodp.outType == "ListMap">
    public List<Map<String,Object>>  ${methodp.name}(Map conditionMap){
         return ${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap);
    }
    public PageBean ${methodp.name}Page(Map conditionMap,int pageNo,int pageSize){
		Integer count = ${methodp.name}Count(conditionMap);
		PageBean pageBean = new PageBean();
		pageBean.setCount(count);
		pageBean.setPageNo(pageNo);
		pageBean.setPageSize(pageSize);
		conditionMap.put("limitStart",pageBean.getStartNo());
		conditionMap.put("limitOffset",pageSize);
		pageBean.setData(${config.objectName?uncap_first}Mapper.${methodp.name}(conditionMap));
		return pageBean;
    }
    public Integer ${methodp.name}Count(Map conditionMap){
	    return ${config.objectName?uncap_first}Mapper.${methodp.name}Count(conditionMap);
    }
</#if>
</#list>
}